package com.kmproject.haifu.mvp.ui.adapter;

import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kmproject.haifu.R;
import com.kmproject.haifu.mvp.model.entity.beans.HouseRentListShowInfoBean;
import com.kmproject.haifu.mvp.model.entity.beans.ObtainedHouseBean;
import com.kmproject.haifu.mvp.presenter.MyStoreLookObtainedPresenter;

import java.util.List;

public class ObtainedHouseAdapter extends BaseQuickAdapter<ObtainedHouseBean, BaseViewHolder> {
    ItemClickCallBack mitemClickCallBack;
    public ObtainedHouseAdapter( @Nullable List<ObtainedHouseBean> data, ItemClickCallBack itemClickCallBack) {
        super(R.layout.mystore_selectstory_item, data);
        this.mitemClickCallBack=itemClickCallBack;
    }

    @Override
    protected void convert(BaseViewHolder helper, ObtainedHouseBean item) {
        helper.<RecyclerView>getView(R.id.mystore_selectstory_item_RecyclerView).setLayoutManager(new LinearLayoutManager(mContext));
        helper.<TextView>getView(R.id.mystore_selectstory_item_title_txt).setText(item.getTime()+"年发布");
        ObtainedHouseItemAdapter obtainedHouseItemAdapter=  new ObtainedHouseItemAdapter(item.getTime(),item.getResult());
        helper.<RecyclerView>getView(R.id.mystore_selectstory_item_RecyclerView).setAdapter(obtainedHouseItemAdapter);
        obtainedHouseItemAdapter.openLoadAnimation(BaseQuickAdapter.SCALEIN);
        obtainedHouseItemAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                mitemClickCallBack.Callback(obtainedHouseItemAdapter.getItem(position));
            }
        });
    }

    public interface  ItemClickCallBack{
        void Callback(HouseRentListShowInfoBean houseRentListShowInfoBean);
    }
}
